package specialClasses

/**
 *@author LikeYouDo
 *@date 2024/12/10 16:31
 */
sealed class Mammal(val name: String)

class Cat(val catName: String): Mammal(catName)
class Human(val humanName: String,val job: String): Mammal(humanName)

fun greetMammal(mammal: Mammal): String{
    when(mammal){
        is Human -> return "Hello ${mammal.name}; You're working as a ${mammal.job}"    // 4
        is Cat -> return "Hello ${mammal.name}"
    }
}

fun main() {
    println(greetMammal(Cat("Snowy")))
    println(greetMammal(Human("Max","work")))
}